package com.swsc.ai.exception;

import com.swsc.ai.enums.CommonResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @describe: 统一异常信息封装
 * @author: 容若
 * @created: 2024-06-20 12:58
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BaseException extends RuntimeException {

    protected CommonResultCode resultCode;

    protected String msg;

    protected Object data;

    public BaseException(CommonResultCode resultCode) {
        this.resultCode = resultCode;
        this.msg = resultCode.getMsg();
    }

    public BaseException(CommonResultCode resultCode, String msg) {
        this.resultCode = resultCode;
        this.msg = msg;
    }

    public BaseException(CommonResultCode resultCode, Object data) {
        this.resultCode = resultCode;
        this.msg = resultCode.getMsg();
        this.data = data;
    }

    public BaseException(CommonResultCode resultCode, String msg, Object data) {
        this.resultCode = resultCode;
        this.msg = msg;
        this.data = data;
    }
}
